Page({
  data: {
    questions: [
      {
        id: 'q1',
        question: '您每周大约进行多少次有氧运动（如快走、跑步、游泳等）？',
        options: [
          { value: '0', text: '0次', score: 0 },
          { value: '1', text: '1-2次', score: 10 },
          { value: '2', text: '3-4次', score: 15 },
          { value: '3', text: '5次以上', score: 20 }
        ]
      },
      {
        id: 'q2',
        question: '您每次有氧运动的持续时间是多久？',
        options: [
          { value: '0', text: '少于30分钟', score: 0 },
          { value: '1', text: '30-60分钟', score: 10 },
          { value: '2', text: '1-2小时', score: 15 },
          { value: '3', text: '超过2小时', score: 20 }
        ]
      },
      {
        id: 'q3',
        question: '您是否定期进行肌肉力量训练，如举重或做俯卧撑？',
        options: [
          { value: '0', text: '从不', score: 0 },
          { value: '1', text: '每月几次', score: 10 },
          { value: '2', text: '每周几次', score: 15 },
          { value: '3', text: '每天', score: 20 }
        ]
      },
      {
        id: 'q4',
        question: '您每周大约吃多少次快餐或外卖？',
        options: [
          { value: '0', text: '5次以上', score: 0 },
          { value: '1', text: '5-6次', score: 10 },
          { value: '2', text: '3-4次', score: 15 },
          { value: '3', text: '1-2次', score: 20 }
        ]
      },
      {
        id: 'q5',
        question: '您每天的饮食中大约包含多少份水果（1份约等于一个中等大小的水果或半杯水果切片）？',
        options: [
          { value: '0', text: '5份以上', score: 20 },
          { value: '1', text: '5-7份', score: 15 },
          { value: '2', text: '1-4份', score: 10 },
          { value: '3', text: '0份', score: 0 }
        ]
      }
    ],
    score: 0,
    evaluation: ''
  },
  onLoad: function() {
    // 页面加载时执行的逻辑
  },
  onSubmit: function(e) {
    let score = 0;
    const selections = e.detail.value;

    // 计算得分
    for (let qid in selections) {
      const question = this.data.questions.find(q => q.id === qid);
      if (question) {
        const selectedOption = question.options.find(o => o.value === selections[qid]);
        if (selectedOption) {
          score += selectedOption.score;
        }
      }
    }

    // 设置评语
    this.setData({
      score: score,
      evaluation: score >= 60 ? '您生活的很健康呐~请继续保持。' : '请好好照顾自己哦~身体是革命的本钱。'
    });
  }
});